<%--
  Created by IntelliJ IDEA.
  User: csnf
  Date: 2024/12/23
  Time: 14:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>学生列表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            background-color: #f4f4f4;
        }
        .container {
            width: 100%;
            max-width: 800px;
            text-align: center;
        }
        form {
            margin-bottom: 20px;
            display: inline-block;
        }
        input[type="text"] {
            padding: 5px;
            width: 200px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        input[type="submit"], .add-button {
            padding: 5px 10px;
            background-color: #4CAF50;
            color: white;
            border: none;
            cursor: pointer;
            border-radius: 4px;
            transition: background-color 0.3s;
        }
        input[type="submit"]:hover, .add-button:hover {
            background-color: #45a049;
        }
        table {
            border-collapse: collapse;
            width: 100%;
            max-width: 800px;
            margin: 0 auto;
            text-align: left;
        }
        th, td {
            padding: 8px;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f2f2f2;
        }
        tr:hover {
            background-color: #f5f5f5;
        }
        a {
            text-decoration: none;
            color: #007BFF;
            margin-right: 10px;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<div class="container">
    <h2>学生列表</h2>
    <form action="StudentServlet">
        <input type="text" name="sName" placeholder="请输入姓名">
        <input type="submit" value="查询">
        <button type="button" class="add-button" onclick="location.href='getAllClazz'">添加</button>
    </form>

    <table>
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th>生日</th>
            <th>性别</th>
            <th>班级</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${stuList}" var="stu">
            <tr>
                <td>${stu.sId}</td>
                <td>${stu.sName}</td>
                <td>${stu.birth}</td>
                <td>${stu.gender}</td>
                <td>${stu.clazz.cName}</td>
                <td>
                    <a href="getStudentById?sId=${stu.sId}">修改</a>
                    <a href="javascript:del(${stu.sId})">删除</a>
                </td>
            </tr>
        </c:forEach>

        <script>
            function del(id){
                if (confirm("确定删除吗？")){
                    location.href="deleteById?sId=" + id;
                }
            }
        </script>
    </table>
</div>
</body>
</html>



